package com.navinfo.platform.basicdatastatistics.service.impl.huashen;

import com.navinfo.platform.basicdatastatistics.dto.AbstractBasicDataDto;
import com.navinfo.platform.basicdatastatistics.dto.yiqi.CustomDto;
import com.navinfo.platform.basicdatastatistics.enums.DataTypeEnum;
import com.navinfo.platform.basicdatastatistics.enums.YardEnum;
import com.navinfo.platform.basicdatastatistics.service.IDataStatisticsService;
import com.navinfo.platform.basicdatastatistics.service.impl.DefaultDataStatisticsService;
import com.navinfo.platform.common.anno.RunningEnv;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.types.DataTypes;
import org.apache.spark.sql.types.Metadata;
import org.apache.spark.sql.types.StructField;

import java.util.ArrayList;
import java.util.List;

@RunningEnv(yard = YardEnum.HUASHEN, dataType = DataTypeEnum.WEEK, interfaceClass = IDataStatisticsService.class)
public class WeekDataStatisticsService extends DefaultDataStatisticsService {

    @Override
    public List<StructField> getCustomSchemas() {
        List<StructField> list = new ArrayList<>();
        list.add(new StructField("run_days", DataTypes.IntegerType, true, Metadata.empty()));
        list.add(new StructField("odo_mileage", DataTypes.LongType, true, Metadata.empty()));
        list.add(new StructField("national_road_mileage", DataTypes.IntegerType, true, Metadata.empty()));
        list.add(new StructField("national_road_duration", DataTypes.IntegerType, true, Metadata.empty()));
        list.add(new StructField("provincial_road_mileage", DataTypes.IntegerType, true, Metadata.empty()));
        list.add(new StructField("provincial_road_duration", DataTypes.IntegerType, true, Metadata.empty()));
        list.add(new StructField("other_road_mileage", DataTypes.IntegerType, true, Metadata.empty()));
        list.add(new StructField("other_road_duration", DataTypes.IntegerType, true, Metadata.empty()));
        return list;
    }

    @Override
    public List<Object> getCustomValues(AbstractBasicDataDto abstractBasicDataDto) {
        CustomDto customDto = (CustomDto) abstractBasicDataDto.getCustomDto();
        List<Object> list = new ArrayList<>();
        list.add(getIntValue(abstractBasicDataDto.getRunDays()));
        list.add(abstractBasicDataDto.getOdoMileage());
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        return list;
    }

    @Override
    public void setCustomInfo(Row row, AbstractBasicDataDto abstractBasicDataDto) {
        CustomDto customDto = new CustomDto();
        customDto.setCustomDtoInfo(row);
        abstractBasicDataDto.setCustomDto(customDto);
    }

    @Override
    public void calcCrossCitiesInfo(Row row, AbstractBasicDataDto basicDataDto){}

    @Override
    public void calcTonKM(Row row, AbstractBasicDataDto basicDataDto){}

    @Override
    public void calcWloadTypeInfo(Row row, AbstractBasicDataDto basicDataDto){};
}
